﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.system.basis
{
    public partial class style : System.Web.UI.Page
    {
        Maticsoft.BLL.style bll = new Maticsoft.BLL.style();
        Maticsoft.BLL.Parts blls = new Maticsoft.BLL.Parts();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["id"] != "0" || string.IsNullOrEmpty(Request["id"]))
                {
                    string where = "id<>0 and partscode like '" + Request["id"] + "%'";
                    hidwhere.Value = where;
                }
                //this.typelist.DataSource = blls.GetList("");
                //this.typelist.DataTextField = "name";
                //this.typelist.DataValueField = "code";
                //this.typelist.DataBind();
                //this.typelist.Items.Insert(0, new ListItem("--请选择部位--", ""));

                Maticsoft222.DBUtility.TreeHelper th = new Maticsoft222.DBUtility.TreeHelper();
                List<TreeNode> allNodes = th.GetAllNodes(blls.GetList("").Tables[0], "code", "name");
                th.AutoTreeView(tv, allNodes);//加载树
                int totalOrders = bll.GetRecordCount(hidwhere.Value);
                AspNetPager1.RecordCount = totalOrders;
            }
        }
        void bindData(string where)
        {
            Repeater1.DataSource = bll.GetListByPage(where, "", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData(hidwhere.Value);
        }

        protected void btnserach_Click(object sender, EventArgs e)
        {
            string where = "id<>0 ";
        //    if (typelist.SelectedItem.Value != "")
        //    {
        //        where += " and partscode = '" + typelist.SelectedItem.Value + "'";
        //    }
        //    if (name.Value != null && !string.IsNullOrEmpty(name.Value))
        //    {
        //        where += " and name like '%" + name.Value + "%'";
        //    }
            hidwhere.Value = where;
            bindData(hidwhere.Value);
        }
    }
}